<?php
set_time_limit(0);
if (isset($_POST['uid']) && isset($_POST['n'])){
    include '../c/config.php';
    //$openid=trim($_POST['op']);
    $uid=$_POST['uid'];
    $name=addslashes(trim($_POST['n']));
    $phone=addslashes(trim($_POST['ph']));
    $nianji=addslashes(trim($_POST['nianji'])); 
    $idcard=addslashes(trim($_POST['idc']));
    $qu=addslashes(trim($_POST['qu']));
    $school=addslashes(trim($_POST['school']));
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
    
    if (6 == $nianji) {
       $queryJ=$mysqli->query("SELECT id from `u6` where uid='".$uid."' and phone='".$phone."' limit 0,1 ");
    }elseif (7 == $nianji) {
       $queryJ=$mysqli->query("SELECT id from `u7` where uid='".$uid."' and phone='".$phone."' limit 0,1 ");
    }elseif (8 == $nianji) {
       $queryJ=$mysqli->query("SELECT id from `u8` where uid='".$uid."' and phone='".$phone."' limit 0,1 ");	
    }else{
       $queryJ=$mysqli->query("SELECT id from `u9` where uid='".$uid."' and phone='".$phone."' limit 0,1 ");
    }

    if($queryJ->num_rows>0){

    }else{
        $mysqli->query("INSERT INTO `uinfo` (`id`, `uid`, `name`,`phone`,`idcard`,`nianji`,`qu`,`school`,`createtime`) VALUES (NULL,'".$uid."', '".$name."','".$phone."','".$idcard."', '".$nianji."','".$qu."','".$school."','".date("Y-m-d H:i:s")."')");


        if (6 == $nianji) {
        	 $mysqli->query("INSERT INTO `u6` (`id`, `uid`, `phone`,`createtime`) VALUES (NULL,'".$uid."', '".$phone."', '".date("Y-m-d H:i:s")."')");
        }elseif (7 == $nianji) {
        	 $mysqli->query("INSERT INTO `u7` (`id`, `uid`, `phone`,`createtime`) VALUES (NULL,'".$uid."', '".$phone."', '".date("Y-m-d H:i:s")."')");
        }elseif (8 == $nianji) {
             $mysqli->query("INSERT INTO `u8` (`id`, `uid`, `phone`,`createtime`) VALUES (NULL,'".$uid."', '".$phone."', '".date("Y-m-d H:i:s")."')");
        }else{
            $mysqli->query("INSERT INTO `u9` (`id`, `uid`, `phone`,`createtime`) VALUES (NULL,'".$uid."', '".$phone."', '".date("Y-m-d H:i:s")."')");
        }

    }
 
    
    $mysqli->close();
    echo json_encode(array('s'=>'y'));
}else{
    echo json_encode(array('s'=>'n'));
}

?>